package net.optix.ip.business
{
	import com.adobe.cairngorm.business.Responder;
	
	import mx.rpc.http.HTTPService;
	
	import net.optix.ip.model.ModelLocator;
	import net.optix.ip.vo.ActionVO;
	import net.optix.ip.vo.CopyrightVO;
	import net.optix.ip.vo.TradeMarkVO;
	
	public class CopyrightDelegate
	{
		private var responder:Responder;
		private var service:HTTPService;
		
		public function	listener():void
		{
			service.method = "POST";
            service.resultFormat	=	HTTPService.RESULT_FORMAT_E4X;
            service.addEventListener("result", responder.onResult);
            service.addEventListener("fault", responder.onFault);
		}
		
		public function recordTradeMark(responder:Responder,vo:TradeMarkVO):void
		{
			this.responder	=	responder;
			service 		= 	new HTTPService();
			service.url		=	ModelLocator.getInstance().url+"/TradeMark/RecordTradeMark";
            this.listener();
            //service.resultFormat	=	HTTPService.RESULT_FORMAT_TEXT;
            service.send({
            	ClientID:vo.clientID,
				TradeMark:vo.tradeMark,
				Excluded:vo.excluded,
				FirstUseDate:vo.firstUseDate,
				Filed:vo.filed,
				SerialNumber:vo.serialNumber,
				Registered:vo.registered,
				RegistrationNumber:vo.registrationNumber,
				RegistrationDate:vo.registrationDate,
				RenewBy:vo.renewBy
            	});
		}
		
		public function assignCopyToFirm(responder:Responder,vo:CopyrightVO):void
		{
			this.responder	=	responder;
			service 		= 	new HTTPService();
			service.url		=	ModelLocator.getInstance().url+"/Copyright/AssignCopyrightToFirm";
            this.listener();
            //service.resultFormat	=	HTTPService.RESULT_FORMAT_TEXT;
            service.send({
            	CopyrightID:vo.copyrightID,
            	MaxBudget:vo.maxBudget,
            	DeadlineDate:vo.deadlineDate,
            	
            	FirmID:vo.firmID
            });
		}
		
		public function acceptAssignCopyright(responder:Responder,vo:CopyrightVO):void
		{
			this.responder	=	responder;
			service 		= 	new HTTPService();
			service.url		=	ModelLocator.getInstance().url+"/Copyright/AcceptAssignCopyright";
            this.listener();
            //service.resultFormat	=	HTTPService.RESULT_FORMAT_TEXT;
            service.send({
            	CopyrightID:vo.copyrightID,
            	BConfirm:vo.bConfirm,
            	FirmID:vo.firmID,
            	ClientID:vo.clientID
            });
		}
		
		public function getCopyrights(responder:Responder,userID:int,role:int):void
		{
			this.responder	=	responder;
			service 		= 	new HTTPService();
			service.url		=	ModelLocator.getInstance().url+"/Copyright/GetCopyrights";
            this.listener();
            //service.resultFormat	=	HTTPService.RESULT_FORMAT_TEXT;
            service.send({
            	UserID:userID,
            	Role:role
            	});
		}
		
		public function getCopyright(responder:Responder,copyrightID:int,userID:int,role:int):void
		{
			this.responder	=	responder;
			service 		= 	new HTTPService();
			service.url		=	ModelLocator.getInstance().url+"/Copyright/GetCopyright";
            this.listener();
            //service.resultFormat	=	HTTPService.RESULT_FORMAT_TEXT;
            service.send({
            	CopyrightID:copyrightID,
            	UserID:userID,
            	Role:role
            	});
		}
		
		public function setCopyright(responder:Responder,vo:CopyrightVO):void
		{
			this.responder	=	responder;
			service 		= 	new HTTPService();
			service.url		=	ModelLocator.getInstance().url+"/Copyright/RecordCopyRight";
            this.listener();
            //service.resultFormat	=	HTTPService.RESULT_FORMAT_TEXT;    
            
           	service.send({
           		ClientID:vo.clientID,
           		Title:vo.title,
           		Created:vo.created,
           		Registered:vo.registered,
           		Registration:vo.registration,
           		IssuedTo:vo.issuedTo,
           		Type:vo.type,
           		Death:vo.death
				 });
		}
		
		public function getCopyrightActions(responder:Responder,copyrightID:int):void
		{
			this.responder	=	responder;
			service 		= 	new HTTPService();
			service.url		=	ModelLocator.getInstance().url+"/Copyright/GetCopyrightActions";
            this.listener();
            //service.resultFormat	=	HTTPService.RESULT_FORMAT_TEXT;
            service.send({
            	CopyrightID:copyrightID
            	});
		}
		
		public function addAction(responder:Responder,vo:ActionVO):void
		{
			this.responder	=	responder;
			service 		= 	new HTTPService();
			service.url		=	ModelLocator.getInstance().url+"/Copyright/AddAction";
            this.listener();
            //service.resultFormat	=	HTTPService.RESULT_FORMAT_TEXT;
            service.send({
				CopyrightID:vo.inventionID,
				Title:vo.title,
				Type:vo.type,
				Description:vo.description,
				FileNames:vo.fileNames,
				Cost:vo.cost
			});
		}
		
		public function getBidCopyrights(responder:Responder,firmID:int):void
		{
			this.responder	=	responder;
			service 		= 	new HTTPService();
			service.url		=	ModelLocator.getInstance().url+"/Copyright/GetBidCopyrights";
            this.listener();
            //service.resultFormat	=	HTTPService.RESULT_FORMAT_TEXT;
            service.send({
				FirmID:firmID
			});
		}
	}
}